<?php

/**
 * This file is part of the Anota project.
 * 2011-2012 Fernando Garcia Huerta <fgarciahue@uoc.edu>
 * 
 * UOC - FUNDAMENTOS DE INFORMÁTICA EN ENTORNOS BIOINFORMÁTICOS - PEC2
 */

/**
 * Autoload needed classes, avoiding use of annoing multiple 
 * 'requires' or 'includes'.
 *
 * @package    Anota
 * @subpackage application
 * @author     Fernando Garcia Huerta <fgarciahue@uoc.edu>
 */
class AnotaClassAutoloader
{

    /**
     * Constructor
     */
    public function __construct()
    {
        spl_autoload_register(array($this, 'loader'));
    }

    /**
     * Loader function.
     *  - looks for classes in the same directory as it lives.
     *  - class extension must be: '.class.php'.
     * 
     * @param string $className 
     */
    private function loader($className)
    {
        $class_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . $className . '.class.php';
        include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . $className . '.class.php';
    }

}

/**
 * Creates an instance of the autoloader class
 */
$autoloader = new AnotaClassAutoloader();
